package com.powernode.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.powernode.domain.SysLoginUser;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author syo 2319615164@qq.com
 * @description SysLoginMapper
 * @date 2024/10/3
 * @Copyright syo
 */
@Mapper
public interface SysLoginUserMapper extends BaseMapper<SysLoginUser> {

    /**
     * 查询权限的sql，通过用户角色标和角色权限表和权限表
     * @param userId    用户Id
     * @return          权限集合
     */
    @Select("select DISTINCT t1.perms from sys_menu t1 join sys_role_menu t2 join sys_user_role t3 on (t1.menu_id = t2.menu_id and t2.role_id = t3.role_id)\n" +
            "where t3.user_id = #{userId}")
    List<String> selectAuthsByUserId(Long userId);
}

